package com.terrace.core.spring.datasource.lookup;

/**
 * 当前线程数据源
 * @author jiangyg
 *
 */
public class DataSourceHolder {
	
	/**
	 * 线程局部变量
	 */
	private static final ThreadLocal<String> THREAD_LOCAL_DATASOURCE = new ThreadLocal<String>();

	/**
	 * 设置数据源
	 * @param dataSourceName
	 */
	public static void setDataSource(String dataSourceName) {
		THREAD_LOCAL_DATASOURCE.set(dataSourceName);
	}
	
	/**
	 * 获取当前线程设置的数据源名称
	 * @return
	 */
	public static String getDataSource() {
		return THREAD_LOCAL_DATASOURCE.get();
	}
	
	/**
	 * 移除当前线程数据源
	 */
	public static void removeDataSource() {
		THREAD_LOCAL_DATASOURCE.remove();
	}

}
